package com.poorstu.web;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import com.common.base.web.BaseAction;
import com.poorstu.manager.AdminMeg;
import com.poorstu.manager.LeaseManager;
import com.poorstu.model.LeaseMod;

public class LeaseAddAction extends BaseAction {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		DynaActionForm dyaction=(DynaActionForm)form;
		//int alluserid=(Integer)request.getSession().getAttribute("alluserid");
		int allUserId=1;
		try{
		String leaseName=(String)dyaction.get("leasename");
		String leaseContent=(String)dyaction.get("leasecontent");
		// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		 //Date date=new Date();
		
		LeaseMod leaseMod=new LeaseMod();
		leaseMod.setLeaseName(leaseName);
		leaseMod.setLeaContent(leaseContent);
		leaseMod.setLeaTime(new Date());
		LeaseManager leaseMag=(LeaseManager)getBean("leaseManager");
		int a=leaseMag.leaseAdd(leaseMod, allUserId);
		if(a==1){
			return mapping.findForward("succ");
		}
		}catch(Exception e) {
			e.printStackTrace();
			return mapping.findForward("failure");
			
		}
		return mapping.findForward("failure");
	}
	

}
